import pygame
import random
#import os
from pygame.locals import *
from defs import *

class Jump(pygame.sprite.Sprite):

   colour = RED

   base_image = pygame.Surface((50, 50))
   base_image.fill(TRANSPARENT)
   base_image.set_colorkey(TRANSPARENT)
   pointlist = [(0,0), (0,50), (50,50), (50,0)]
   pygame.draw.polygon(base_image, colour, pointlist)

   def __init__(self):
      pygame.sprite.Sprite.__init__(self)
      self.image = self.base_image.copy()
      x = int(SCREENRECT.width * random.random())
      y = int((SCREENRECT.height - FONT_SIZE) * random.random())
      self.rect = self.image.get_rect(center=(x,y))

   def update(self):
      self.wrap()

   def wrap(self):
      if (self.rect.center[0] < 0):
         self.rect.move_ip(SCREENRECT.width, 0)
      elif (self.rect.center[0] >= SCREENRECT.width):
         self.rect.move_ip(-SCREENRECT.width, 0)            

      if (self.rect.center[1] <  FONT_SIZE):
         self.rect.move_ip(0, SCREENRECT.height - FONT_SIZE)
      elif (self.rect.center[1] >= SCREENRECT.height):
         self.rect.move_ip(0, -SCREENRECT.height + FONT_SIZE)
